package com.atguigu.map;
import com.atguigu.set.User;
import org.junit.Test;

import java.util.Comparator;
import java.util.TreeMap;

public class TreeMapTest {
    @Test
    public void test(){
        Comparator<User> com=(o1,o2)->{
            return o1.getName().compareTo(o2.getName());
        };
        TreeMap<User,Integer> map=new TreeMap<User,Integer>(com);
        User u1=new User(12,"Tom");
        User u2=new User(13,"Jery");
        User u3=new User(18,"Rose");
        User u4=new User(9,"Michael");
        map.put(u1,98);
        map.put(u2,77);
        map.put(u3,55);
        map.put(u4,66);
        System.out.println(map);

    }
}
